Skip to content

perf: disable dts emit for workspace packages and enable zod compile - #41

Open
mrboxs wants to merge 1 commit into
mainfrom
perf/disable-dts-for-faster-builds
Open

perf: disable dts emit for workspace packages and enable zod compile#41
mrboxs wants to merge 1 commit into
mainfrom
perf/disable-dts-for-faster-builds

Conversation

@mrboxs

@mrboxs mrboxs commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Why

Building @altstack/api took ~20s while every other workspace package built in 1–4s. Investigation showed 100% of that time was spent in .d.ts generation (rolldown-plugin-dts + tsgo): the oRPC Implementer type carries the whole contract map, so procedures.d.mts alone expanded to ~25k lines / 1.07 MB (1.94 MB total), requiring ~65k module resolutions.

Those declarations are never consumed: all packages are private, every exports entry resolves to src via devExports, no publishConfig references any .d.mts, and Docker runtimes only ship .mjs + src.

What changed

  • Set dts: false in vite.config.ts for packages/api, auth, db, env, shared, and apps/server (with a comment explaining why). packages/ui intentionally untouched — it has no build script and is consumed purely from src.
  • Added import 'zod/compile' above the zod schemas in packages/api/src/contracts/{altstack,health}.ts and packages/shared/src/schemas/{project,role}.ts to enable JIT-compiled parsers at runtime.

Measured results (vp pack per package)

Package Before After
api ~19–23s ~90ms
auth ~2.4s ~50ms
db ~3s ~55ms
env ~1s ~80ms
shared ~1s ~40ms
server ~4s ~70ms

Verification

  • Full vp run -r build: success (remaining ~28s is the Nitro web build, 0 warnings/errors)
  • Root vp check: all 130 files formatted, 88 files with no warnings/lint/type errors
  • @altstack/api tests: 10/10 passed

Trade-off

vp pack no longer acts as an incidental typecheck (transpile-only, like esbuild). Type safety stays covered by vp check, which ready runs before build and tests.

Summary by CodeRabbit

  • Chores
    • Updated package build configuration to stop generating TypeScript declaration files.
    • Existing workspace source resolution and type checking remain in place.
    • Updated validation schema modules to support Zod compilation during builds.
    • No changes were made to API contracts, schemas, or exported functionality.

Skip .d.ts generation in vp pack for api, auth, db, env, shared and server: all packages are private, exports resolve to src via devExports, and nothing consumes dist declarations. The oRPC Implementer type alone expanded to ~25k lines / 1.9 MB of .d.ts (~20s). Typechecking stays covered by vp check.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Advanced

Run ID: 9ebf57b8-4492-4687-868e-b7406aa27100

📥 Commits

Reviewing files that changed from the base of the PR and between 3e23bfa and 44f9cbf.

📒 Files selected for processing (10)
  • apps/server/vite.config.ts
  • packages/api/src/contracts/altstack.ts
  • packages/api/src/contracts/health.ts
  • packages/api/vite.config.ts
  • packages/auth/vite.config.ts
  • packages/db/vite.config.ts
  • packages/env/vite.config.ts
  • packages/shared/src/schemas/project.ts
  • packages/shared/src/schemas/role.ts
  • packages/shared/vite.config.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The change disables Vite declaration generation for the server and workspace packages. It also adds zod/compile side-effect imports to selected API contracts and shared schemas.

Changes

Build and schema configuration

Layer / File(s) Summary
Disable build declaration generation
apps/server/vite.config.ts, packages/*/vite.config.ts
The Vite configurations replace the tsgo declaration generator with dts: false.
Enable Zod compile support
packages/api/src/contracts/*, packages/shared/src/schemas/*
The selected contract and schema modules add side-effect imports for zod/compile.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 44f9c

This change makes affected private package builds transpile-only and enables compiled Zod parsers in selected schemas. Current validation indicates the build and typechecking contracts remain intact, with no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both primary changes: disabling declaration-file generation for workspace packages and enabling Zod compilation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/disable-dts-for-faster-builds

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant